
//
package SMUVE;
import SMUVE.*;
public class Item {
private String name;
private String description;
private String location;
private boolean carried;
private boolean locked;
private static final String delimiter = SMUVE.Msg_Pipe.delimiter;

public Item(String name, String description, String location)
{
	this.name=name;
	this.description=description;
	this.location=location;
	carried=false;
}
public void pickedUp()
{
	carried=true;
}
public void dropped()
{
	carried=false;
}
public boolean is_carried()
{
	return carried;
}
public String get_name() {
	return name;
}
public void set_name(String name) {
	this.name = name;
}
public String get_description() {
	return description;
}
public void set_description(String description) {
	this.description = description;
}
public String get_location() {
	return location;
}
public void set_location(String location) {
	this.location = location;
}
public boolean is_locked() {
	return locked;
}
public void set_locked(boolean locked) {
	this.locked = locked;
}
public void set_carried(boolean carried) {
	this.carried = carried;
}
public String toString()
{
	return name + delimiter + description + delimiter + location;
}

public static Item fromString(String str) throws Exception
{
	String[] args = str.split("\\" + delimiter);
	if (args.length < 4) // 1 + number of attributes in class
		throw (new InvalidMessageException("invalid Item"));
	return(new Item(args[1], args[2], args[3]));
}
}
